using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Jeffrey.XFramework.XCrawl;

namespace Jeffrey.Xuthus
{
    public partial class XSettingsForm : Form
    {
        public XSettingsForm(XController xc, CrawlController cc)
        {
            m_XController = xc;
            m_CrawlController = cc;

            InitializeComponent();
        }

        public DataSettings DataSettings { get { return m_datasetting; } }

        public void InitializeStuffs()
        {
            SetStuffs();
        }

        public void Enable()
        {
            XSettingPropertyGrid.Enabled = true;
        }

        public void Disable()
        {
            XSettingPropertyGrid.Enabled = false;
        }

        public void SetStuffs()
        {
            m_datasetting.BlockedRetry      = m_CrawlController.CrawlOrder.BlockedRetry;
            m_datasetting.DefaultEncoding   = m_CrawlController.CrawlOrder.DefaultEncoding;
            m_datasetting.Depth             = m_CrawlController.CrawlOrder.Depth;
            m_datasetting.DnsCache          = m_CrawlController.CrawlOrder.DnsCache;
            m_datasetting.Interval          = m_CrawlController.CrawlOrder.Interval;
            m_datasetting.TimeOut           = m_CrawlController.CrawlOrder.TimeOut / 1000;
            m_datasetting.TotalPages        = m_CrawlController.CrawlOrder.TotalPages / (10 * 1000);
            m_datasetting.KeepAlive         = m_CrawlController.CrawlOrder.KeepAlive;
            m_datasetting.GarbageCollection = m_CrawlController.CrawlOrder.GC;

            //whether or not to clear the uris...

            XSettingPropertyGrid.Refresh();
        }

        private XController m_XController;
        private CrawlController m_CrawlController;
    }
}